﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL.Database.EasierMVC.DB.EF;
using DAL.Database.Db;
using BLL.Service;

namespace BLL.Service.EasierMVC.EF
{
    public class RepositoryFactory : IRepositoryFactory
    {
        public IRepository<T> Create<T>()
            where T : class, new()
        {
            return new CustomRepository<T>(DbContextFactory.Create(null));
        }

        public IRepository<T> Create<T>(string connectionstring)
            where T : class, new()
        {
            return new CustomRepository<T>(DbContextFactory.Create(connectionstring, null));
        }

        public IRepository<T> Create<T>(Action<string> log)
            where T : class, new()
        {
            return new CustomRepository<T>(DbContextFactory.Create(log));
        }
            
        public IRepository<T> Create<T>(string connectionstring, Action<string> log)
            where T : class, new()
        {
            return new CustomRepository<T>(DbContextFactory.Create(connectionstring, log));
        }
    }
}
